<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *售后列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
//售后列表
if($_RQ['op']=='list' || $_RQ['op']=='fromclass'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=array();
	$params=array('storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']);
	if($_RQ['status']!='all'){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}else{
		$return['params']['status']=$_RQ['status'];
	}
	if($_RQ['id'] && $_RQ['op']=='fromclass'){
		$params['classid']=intval($_RQ['id']);
		$return['params']['classid']=$_RQ['id'];
		$this->session('classid',$params['classid']);
	}
	if($this->session('classid')){
		$params['classid']=$this->session('classid');
		$return['params']['classid']=$this->session('classid');
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.$_RQ['title'].'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile']=$_RQ['mobile'];
		$return['params']['mobile']=$_RQ['mobile'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = $_RQ['psize']?:10;
	if($_RQ['psize']){
		$return['params']['psize']=$_RQ['psize'];
	}
	$list=pdo_getslice('jy_yxw_xuesheng',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['member']=$this->model('xuesheng')->member_show($item['id']);
			if($item['danganimage1'] && $item['danganimage2']){
				$item['isdangan']=1;
			}
			if(!$item['danganimage1'] || !$item['danganimage2']){
				$item['isdangan']=2;
			}
			if(!$item['danganimage1'] && !$item['danganimage2']){
				$item['isdangan']=0;
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	//页面显示设置
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'export'=>'export',
		'list'=>array('data'=>'list','del_message'=>'确认删除该售后吗？','total'=>$total,'psize'=>$psize,'edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'member','title'=>'用户信息','type'=>'member'),
			array('name'=>'sn','title'=>'编号','type'=>'string'),
			array('name'=>'classid','title'=>'售后群','type'=>'select','options'=>'class'),
			array('name'=>'jobgs','title'=>'反馈公司','type'=>'string'),
			array('name'=>'jobtime','title'=>'反馈时间','type'=>'string'),
			array('type'=>'img_string','title'=>'反馈薪资','data'=>array(
				array('title'=>'试用期：','name'=>'jobfee1'),
				array('title'=>'转正：','name'=>'jobfee2')
				)
			),
			array('type'=>'img_string','title'=>'面试情况','data'=>array(
				array('title'=>'面试次数：','name'=>'miannum'),
				array('title'=>'offer次数：','name'=>'offernum')
				)
			),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'createtime','title'=>'日期','type'=>'time'),
		),'action'=>array(
			array('type'=>'href','action'=>'jy_yxw/jiuye.list/setjiuye','title'=>'反馈跟进','show'=>array('status'=>array(13))),
			array('type'=>'href','action'=>'jy_yxw/jiuye.jiuye_log/','title'=>'跟进记录','show'=>array('status'=>array(13,14,15,16,21,22,23))),
		),'batch'=>$batch),
		'search'=>array(
			array('type'=>'string','width'=>'15','title'=>'手机号','name'=>'mobile','help'=>''),
			array('type'=>'string','width'=>'15','title'=>'售后名称','name'=>'title','help'=>''),
			array('name'=>'status','width'=>'15','title'=>'状态','type'=>'radio','options'=>'status'),
			
			//array('name'=>'storeid','width'=>'15','title'=>'所属门店','type'=>'select','options'=>'stores'),
		),
	);
	if(!$this->session('classid')){
		$htmls['search'][]=array('name'=>'classid','width'=>'15','title'=>'售后群','type'=>'select','options'=>'class');
	}
	//$return['stores']=$this->getall('store',array('uniacid'=>$_SESSION['uniacid']),array('id','title'));
	$return['class']=$this->getall('class',array('storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
	$return['status']=$this->xuesheng_status;
	$return['status']['all']='全部';
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='setjiuye'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		if($post['status']==14 && (!$post['jobgs'] || !$post['jobtime'])){
			exi('请填写反馈公司，反馈时间！','error');
		}
		$update=array('status'=>$post['status']);
		if($post['status']==13){
			$update=array('status'=>$post['status'],'miannum'=>$post['miannum'],'offernum'=>$post['offernum']);
		}elseif($post['status']==14){
			$update=array('status'=>$post['status'],'jobgs'=>$post['jobgs'],'jobgw'=>$post['jobgw'],'jobtime'=>$post['jobtime'],'jobfee1'=>$post['jobfee1'],'jobfee2'=>$post['jobfee2']);
		}
		pdo_update('jy_yxw_xuesheng',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		$post['xueshengid']=$id;
		unset($post['id']);
		$this->model('uplog')->upjiuye_log($post);
		exi('操作成功！','','goback');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_xuesheng',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	}else{
		exi('请先选择售后','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'编辑反馈',
	);
	$htmls['edit']=array(
			array('name'=>'status','title'=>'跟进状态','type'=>'radio','options'=>'status'),
			array('name'=>'miannum','title'=>'累计面试次数','type'=>'unitstring','unit'=>'次','show'=>array('status'=>13)),
			array('name'=>'offernum','title'=>'累计拿到offer次数','type'=>'unitstring','unit'=>'次','show'=>array('status'=>13)),
			array('name'=>'remark','title'=>'跟进情况','type'=>'text','show'=>array('status'=>13)),
			array('name'=>'jobgs','title'=>'反馈公司','type'=>'string','show'=>array('status'=>14)),
			array('name'=>'jobgw','title'=>'反馈岗位','type'=>'string','show'=>array('status'=>14)),
			array('name'=>'jobtime','title'=>'反馈时间','type'=>'string','show'=>array('status'=>14)),
			array('name'=>'jobfee1','title'=>'试用期薪资','type'=>'string','show'=>array('status'=>14)),
			array('name'=>'jobfee2','title'=>'转正薪资','type'=>'string','show'=>array('status'=>14)),
			array('name'=>'remark','title'=>'情况描述','type'=>'text','show'=>array('status'=>array(15,16,21,22,23,24))),
	);
	$return['htmls']=$htmls;
	$return['status']=array(
			13=>'日常待反馈跟进',
			14=>'已成功反馈',
			15=>'异常反馈',
			16=>'超期反馈',
			21=>'二次反馈',
			22=>'取消反馈',
			23=>'延迟反馈',
			24=>'放弃反馈',
	);
	exi($return);
}
if($_RQ['op']=='look'){
	$return=array();
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_yxw_xuesheng',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		$member=pdo_get('jy_yxw_member',array('id'=>$item['memberid'],'uniacid'=>$_SESSION['uniacid']));
		$item=array_merge($member,$item);
	}else{
		//exi('请选择客户！','error');
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'look'=>array(
			array('type'=>'string','title'=>'售后名称','name'=>'title'),
			array('type'=>'string','title'=>'手机号','name'=>'mobile'),
			array('type'=>'string','title'=>'备用手机号','name'=>'mobile2'),
			array('name'=>'from_type','title'=>'渠道','type'=>'radio','options'=>'from_type'),
			array('name'=>'from1_type','title'=>'实体来源渠道','type'=>'radio','options'=>'member_from1_type','show'=>array('from_type'=>1)),
			array('name'=>'from2_type','title'=>'网络来源渠道','type'=>'radio','options'=>'member_from2_type','show'=>array('from_type'=>2)),
			array('type'=>'string','title'=>'微信号','name'=>'wechat'),
			array('type'=>'string','title'=>'邮箱','name'=>'email'),
			array('type'=>'string','title'=>'QQ','name'=>'qq'),
			array('type'=>'string','title'=>'专业','name'=>'zhuanye'),
			array('type'=>'string','title'=>'毕业学校','name'=>'school'),
			array('type'=>'radio','title'=>'学历','name'=>'xueli','options'=>'xueli_type'),
			array('type'=>'string','title'=>'应聘岗位','name'=>'gangwei'),
			array('type'=>'string','title'=>'工作经验','name'=>'workdesc'),
			array('type'=>'radio','title'=>'性别','name'=>'sex','options'=>'sex'),
			array('type'=>'string','title'=>'生日','name'=>'birth','help'=>''),
			array('type'=>'pcd','title'=>'户籍','name'=>'pcd','help'=>''),
			array('type'=>'string','title'=>'身份证号码','name'=>'cardno','help'=>''),
			array('type'=>'image','title'=>'身份证正面','name'=>'cardimg1','help'=>''),
			array('type'=>'image','title'=>'身份证背面','name'=>'cardimg2','help'=>''),
			array('type'=>'string','title'=>'详细地址','name'=>'address','help'=>''),
			array('name'=>'sn','title'=>'编号','type'=>'string'),
			array('name'=>'classid','title'=>'售后群','type'=>'select','options'=>'class'),
			array('name'=>'jobgs','title'=>'反馈公司','type'=>'string'),
			array('name'=>'jobtime','title'=>'反馈时间','type'=>'string'),
			array('name'=>'jobfee1','title'=>'试用期薪资','type'=>'string'),
			array('name'=>'jobfee2','title'=>'转正薪资','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)
	);
	$return['status']=$this->xuesheng_status;
	$return['sex']=$this->sex;
	$return['xueli_type']=$this->xueli_type;
	$return['from_type']=$this->member_from_type;
	$return['member_from1_type']=$this->member_from1_type;
	$return['member_from2_type']=$this->member_from2_type;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='export'){
	//售后列表
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['status']!='all'){
		$params['status']=intval($_RQ['status']);
	}
	if($this->session('classid')){
		$params['classid']=$this->session('classid');
	}
	$return['params']['status']=$_RQ['status'];
	if(!empty($_RQ['title'])){
		$params['title like']='%'.$_RQ['title'].'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile']=$_RQ['mobile'];
		$return['params']['mobile']=$_RQ['mobile'];
	}
	$list=pdo_getall('jy_yxw_xuesheng',$params,$fields);
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
		}
	}
	$header=array(
		'id'=>'售后ID',
		'title'=>'售后姓名',
		'mobile'=>'手机号',
		'mobile2'=>'手机号',
		'createtime'=>'注册时间',
	);
	model('core/tools')->export2excel($header,$list,'售后数据');
}
if($_RQ['op']=='del'){
	exi('不能删除！','error');	
}